
class Emitter {
    constructor() {
        this.events = []
    }
    on(event, cb) {
        this.events[event].push(cb)
    }
    emit(event, ...args) {
        this.events[event].map(callback => callback(args))
    }
    once(event, cb) {
        function wrapFn(...args) {
            this.off(event, wrapFn)
            cb.call(this, ...args)
        }
        this.on(event, wrapFn)
    }
    off(event, cb) {
        this.events[event].filter(callback => callback != cb)
    }
}